package fr.iut.tp3.view.components;

import java.awt.Color;
import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;

import fr.iut.tp3.model.UtilisateurImpl.Privilege;


public class PrivilegeCellRenderer extends DefaultTableCellRenderer {
	/**
	 * 
	 */
	private static final long serialVersionUID = -1426168754798431054L;

	public PrivilegeCellRenderer() {
	}

	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		if(value instanceof Integer){
			Integer tmp = (Integer)value;
			switch (tmp) {
			//admin
			case 0:	
				setBackground(Color.RED);
				setText(Privilege.ADMIN.getLabel());
				break;
			//utilisateur	
			case 1:
				setBackground(Color.BLUE);
				setText(Privilege.UTILISATEUR.getLabel());
				break;
			//invité	
			case 2:
				setBackground(Color.YELLOW);
				setText(Privilege.INVITE.getLabel());
				break;
			default:
				break;
			}
		}
		return this;
	}
}